package org.budo.graph.druid.filter.connection;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @author limingwei
 * @see com.alibaba.druid.support.profile.Profiler
 */
public class ActiveConnectionProfiler {
    private static ThreadLocal<List<Object>> profilerList = new ThreadLocal<List<Object>>();

    public static void initLocal() {
        profilerList.set(new LinkedList<Object>());
    }

    public static void enter(Object current) {
        List<Object> list = profilerList.get();

        if (null != list) {
            list.add(current);
        }
    }

    public static List<Object> getProfilerListCopy() {
        List<Object> list = profilerList.get();

        if (null != list) {
            return new ArrayList<Object>(list);
        }
        return null;
    }
}